//
//  ViewController.m
//  10.Making Arrays
//
//  Created by iD Student on 7/8/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    stringArray = [[NSArray alloc] initWithObjects:@"Text1", @"Text2", @"Text3" , nil];
    
    mutableStringArray = [[NSMutableArray alloc]init];
    
    for (int i = 0; i < 3; i++) {
        [mutableStringArray addObject:[NSString stringWithFormat:@"Text%d", (i+1)]];
    }
    image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    image.image = [UIImage imageNamed:@"soccerball.png"];
    [self.view addSubview:image];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:[self view]];
    NSLog([NSString stringWithFormat:@"Touches began at location X:%f Y:%f", touchPoint.x, touchPoint.y]);
    
    [UIView animateWithDuration:2 animations:^{
        image.center = touchPoint;
    }];
    
}

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchPoint = [touch locationInView:[self view]];
    CGPoint previousTouchPoint = [touch previousLocationInView:[self view]];
    NSLog([NSString stringWithFormat:@"Touches moved from location X:%f Y:%f to X:%f Y:%f", previousTouchPoint.x, previousTouchPoint.y, currentTouchPoint.x, currentTouchPoint.y]);
    image.center = currentTouchPoint;
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint endPoint = [touch locationInView:[self view]];
    NSLog([NSString stringWithFormat:@"Touches ended at location X:%f Y:%f", endPoint.x, endPoint.y]);
}

@end
